<template>
  <header>
    <div class="banxin tanxin header_in">
      <section>欢迎来到叩丁狼商城</section>
      <ul>
        <li class="avatar_li" @click="goUser">
          <img
            width="26"
            class="avater"
            src="../assets/images/userImg.png"
            alt=""
          />用户名：有课
        </li>
        <li>我的积分：--</li>
        <li>获取积分</li>
        <li>叩丁狼官网</li>
        <li class="header_btn cart_btn" v-if="isLogin">
          <img src="../assets/images/Shopping.png" alt="" />
          <span>购物车</span>
          <b>0</b>
        </li>
        <li class="header_btn login_btn" v-else @click="goLogin">登录</li>
      </ul>
    </div>
  </header>
</template>

<script>
  import { mapActions } from "vuex";
export default {
  
  data() {
    return {
      isLogin: false, // 默认false未登录
    };
  },
  methods: {
    ...mapActions(['openToastAClose']),
    goLogin() {
      // ？  需要改变登录那个框的v-show的状态
      // 触发mutations 去 打开login
      this.$store.commit("changeLoginShow", true);
    },
    goUser() {
    //   this.$store.commit("openToast", {
    //     show: true,
    //     content: "登录成功",
    //     icon: "success",
    //   });
    this.openToastAClose({
         show: true,
        content: "登录成功",
        icon: "success",
    })
    },
  },
};
</script>
 
<style lang = "less" scoped>
@import "../assets/base.less";
header {
  background: @black;
  height: 40px;
  color: #fffefe;
  font-size: 14px;
  .header_in {
    align-items: center;
    height: 40px;
    ul {
      display: flex;
      height: 40px;
      align-items: center;
      li {
        margin-right: 20px;
        &.avatar_li {
          /* border-radius: 50%; */
          height: 26px;
          display: flex;
          align-items: center;
          .avater {
            border-radius: 50%;
          }
        }
        &.header_btn {
          width: 124px;
          height: 40px;
          background: @blue;
          cursor: pointer;
        }
        &.login_btn {
          text-align: center;
          line-height: 40px;
        }
        &.cart_btn {
          display: flex;
          align-items: center;
          justify-content: center;
          span {
            margin-left: 8px;
            margin-right: 6px;
          }
          b {
            width: 22px;
            height: 22px;
            background: @orange;
            border-radius: 11px;
            text-align: center;
            line-height: 22px;
          }
        }
      }
    }
  }
}
</style>